package com.briup.ptp.utils;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @Classname Result
 * @Description TODO
 * @Date 2023/12/27 14:47
 * @Created by ASUS
 * @Version v1.0.0
 */
@AllArgsConstructor
@Data
public class Result<T> {
    private int code;
    private String mseeage;
    private T data;

    public Result(ResultCode resultCode){
        this.code=resultCode.code();
        this.mseeage=resultCode.message();
    }

    public Result(ResultCode resultCode , T data){
        this(resultCode);
        this.data=data;
    }

    static  public  Result error(ResultCode resultCode){
        return  new Result(resultCode);
    }

    static public  Result  success(){
        return new Result(ResultCode.SUCCESS);
    }

    static public <T> Result success(T data){
        return new Result(ResultCode.SUCCESS,data);
    }
}
